<template>
	<div class="mt-header">
		<mt-header :title="title">
			<div slot="left">
			    <mt-button icon="back" v-on:click="back">返回</mt-button>
			    <!--<mt-button v-on:click="close">关闭</mt-button>-->
			</div>
			<mt-button icon="more" slot="right" @click="topMore=true"></mt-button>
		</mt-header>
	    <mt-actionsheet :actions="actions" v-model="topMore"></mt-actionsheet>
	</div>
</template>
<script>
import { Toast } from 'mint-ui';
export default {
	props: ['title'],
	data() {
		return {
			moreVisible:false,
			topMore: false,
			actions:[
				{
					name: '九宫格',
					method: this.toGrid
				},
				{
					name: '面板',
					method: this.toPanel
				}
			]
		}
	},
	methods: {
		back(){
			// 当在一级目录下时点回退直接退出微服务
			if(this.$route.path=='/'||this.$route.path=='/mine'){
				try {
			 		this.close();
				} catch (e) {
				}
			}else{
				this.$router.go(-1);
			}
		},
		close(){
			try {
		 		('iOS'==plus.os.name)?plus.nativeUI.confirm('确认退出？', (e) => {
						if(e.index>0){
							plus.runtime.quit();
						}
				}, 'LDY', ['取消','确定']):(confirm('确认退出？')&&plus.runtime.quit());
			} catch (e) {}
		},
		toGrid(){
			this.$router.push({path:'/grid'});
		},
		toPanel(){
			this.$router.push({path:'/panel'});
		}
	}
}
</script>